﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace iTelluro.Explorer.Program.Setting
{
   
        public static class AppSetting
        {
            static AppSetting()
            {
                //端口
                var port = ConfigurationManager.AppSettings["ListenPort"];
                if (string.IsNullOrEmpty(port))
                    port = "80";
                ListenPort = port;

                //访问地址
                ListenIps = new List<string>();
                var ips = ConfigurationManager.AppSettings["ListenIps"];
                if (string.IsNullOrEmpty(ips))
                {
                    ListenIps.Add(string.Format("http://localhost:{0}", port));
                    ListenIps.Add(string.Format("http://127.0.0.1:{0}", port));
                }
                else
                {
                    var urls = ips.Split(',');
                    foreach (var url in urls)
                    {
                        ListenIps.Add(string.Format("http://{0}:{1}", url, port));
                    }
                }

                //数据发布地址
                var dataurl = ConfigurationManager.AppSettings["Url"];
                if (string.IsNullOrEmpty(dataurl))
                    dataurl = "http://localhost:8080/";
                Url = dataurl;

                //渲染图发布地址
                var imageUrl = ConfigurationManager.AppSettings["ImageUrl"];
                if (string.IsNullOrEmpty(imageUrl))
                    imageUrl = "http://localhost:8080/";
                ImageUrl = imageUrl;

                //渲染图发布路径
                var publishDir = ConfigurationManager.AppSettings["publishDir"];
                PublishDir = publishDir;
                
                //雷达图发布路径
                var leidaurl=ConfigurationManager.AppSettings["leidaurl"];
                if (string.IsNullOrEmpty(leidaurl))
                    leidaurl = "http://localhost:8080/";
                Leidaurl = leidaurl;

                //雷达图发布路径
                var publishDIR = ConfigurationManager.AppSettings["DeilaDir"];
                LeiDarDIR = publishDIR;

            }

            public static string Url
            {
                get;
                private set;
            }
            public static string Leidaurl
            {
                get;
                private set;
            }

            public static string PublishDir
            {
                get;
                private set;
            }
            public static string LeiDarDIR
            {
                get;
                private set;
            }
            public static string ImageUrl
            {
                get;
                private set;
            }


            public static IList<string> ListenIps
            {
                get;
                private set;
            }

            public static string ListenPort
            {
                get;
                private set;
            }

        }
    
}
